<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="generator" content="pandoc">
  <meta name="author" content="杨志宏">
  <title>利用 Markdown 制作在线幻灯片</title>
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
  <link rel="stylesheet" href="reveal.js/css/reset.css">
  <link rel="stylesheet" href="reveal.js/css/reveal.css">
  <style>
      code{white-space: pre-wrap;}
      span.smallcaps{font-variant: small-caps;}
      span.underline{text-decoration: underline;}
      div.column{display: inline-block; vertical-align: top; width: 50%;}
  </style>
  <style>
code.sourceCode > span { display: inline-block; line-height: 1.25; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode { white-space: pre; position: relative; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
code.sourceCode { white-space: pre-wrap; }
code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
    color: #aaaaaa;
  }
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
  </style>
  <link rel="stylesheet" href="reveal.js/css/theme/black.css" id="theme">
  <link rel="stylesheet" href="yangzh.css"/>
  <!-- Printing and PDF exports -->
  <script>
    var link = document.createElement( 'link' );
    link.rel = 'stylesheet';
    link.type = 'text/css';
    link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js/css/print/pdf.css' : 'reveal.js/css/print/paper.css';
    document.getElementsByTagName( 'head' )[0].appendChild( link );
  </script>
  <!--[if lt IE 9]>
  <script src="reveal.js/lib/js/html5shiv.js"></script>
  <![endif]-->
</head>
<body>
  <div class="reveal">
    <div class="slides">

<section id="title-slide">
  <h1 class="title">利用 Markdown 制作在线幻灯片</h1>
  <p class="author"><a href="http://yangzh.cn">杨志宏</a></p>
  <p class="date">2019-11</p>
</section>

<section><section id="原理及优势" class="title-slide slide level1"><h1>原理及优势</h1></section><section id="原理" class="slide level2">
<h2>原理</h2>
<p><strong>原理</strong>：</p>
<p>使用 pandoc 工具将 markdown 文本转换为 revealjs 格式的 html 文件，然后利用基于 git 技术的代码托管网站提供的免费页面服务实现在线幻灯片。</p>
<p><strong>流程：</strong></p>
<ol type="1">
<li>使用编辑器书写 markdown 文本。</li>
<li>使用 pandoc 转化为 html 文件。</li>
<li>发布到网络（通常为代码托管仓库）。</li>
</ol>
</section><section id="优势与不足" class="slide level2">
<h2>优势与不足</h2>
<ol type="1">
<li>能快速制作幻灯片，节约大量时间。</li>
<li>文档的逻辑结构更为清晰，便于修改。</li>
<li>能发布到网络，有利于学习与反馈。</li>
<li>功能上相对 PPT 而言弱一些（如动画）。</li>
<li>需要了解 Git 工具、markdown 语法和一定的前端基础知识，具有一定的学习成本。</li>
</ol>
</section></section>
<section><section id="如何实现" class="title-slide slide level1"><h1>如何实现</h1></section><section id="准备工作" class="slide level2">
<h2>准备工作</h2>
<ul>
<li>下载并安装<a href="https://baidu.com">git</a>工具。</li>
<li>下载并安装 <a href="https://pandoc.org">pandoc</a> 工具。</li>
<li>下载在线演示工具 <a href="https://revealjs.com">reveal.js</a>，解压到合适目录，并将目录名称改为<code>revealjs</code>。</li>
<li>安装合适的编辑器。推荐开源编辑器： <a href="https://code.visualstudio.com/">VS code</a>。</li>
</ul>
</section><section id="使用-markdown-书写内容" class="slide level2">
<h2>使用 markdown 书写内容</h2>
<ol type="1">
<li><p>首先，在编辑 markdown 文档的时候，需要遵守 <a href="https://daringfireball.net/projects/markdown/syntax">Markdown 语法</a>。</p></li>
<li><p>其次，还需要遵守 pandoc 制定的一些规则。如：在文档开头使用<code>%</code>加入文档标题、作者、时间等元信息：</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode markdown"><code class="sourceCode markdown"><span id="cb1-1"><a href="#cb1-1"></a>% 利用 Markdown 制作在线 PPT</span>
<span id="cb1-2"><a href="#cb1-2"></a>% <span class="ot">[杨志宏](http://yangzh.cn)</span></span>
<span id="cb1-3"><a href="#cb1-3"></a>% 2019-11</span></code></pre></div></li>
<li><p>注意文件保存的位置，将 markdown 文本文件保存到与<code>reveal.js</code>同一级别的目录中。</p></li>
</ol>
</section><section id="使用-pandoc-将-markdown-转化为-html" class="slide level2">
<h2>使用 pandoc 将 markdown 转化为 html</h2>
<p>在项目目录中，执行如下命令：</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1"></a><span class="ex">pandoc</span> -t revealjs -s demo.md -o index.html -c yangzh.css</span></code></pre></div>
<p>上述命令将<code>demo.md</code> 文档，转化为<code>index.html</code>，其中参数<code>-c yangzh.css</code>用来指定自定义的样式表，可以不加。现在使用浏览器打开 html 文件，即可看到演示成果。</p>
</section><section id="使用-git-工具将内容发布到网络" class="slide level2">
<h2>使用 git 工具将内容发布到网络</h2>
<ol type="1">
<li>创建仓库。</li>
<li>推送修改。</li>
<li>开通 pages 服务。</li>
</ol>
<p>详细操作参见 <a href="https://yangjh.gitee.io/appendix/git/pages.html">使用 Pages 服务建立静态网站</a>。</p>
</section></section>
<section><section id="进阶操作" class="title-slide slide level1"><h1>进阶操作</h1></section><section id="如何插入视频" class="slide level2">
<h2>如何插入视频</h2>
<p>使用 markdown 语法中插入图片的语法，只不过将图片替换为视频，例如：</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode markdown"><code class="sourceCode markdown"><span id="cb3-1"><a href="#cb3-1"></a>![](anova.mp4)</span></code></pre></div>
</section><section class="slide level2">

<p><video data-src="anova.mp4" controls=""><a href="anova.mp4">Video</a></video></p>
</section><section id="如何插入数学公式" class="slide level2">
<h2>如何插入数学公式</h2>
<p>pandoc、markdown以及html都支持数学公式的显示。</p>
<ol type="1">
<li>行内公式，如<span class="math inline"><em>y</em> = <em>b</em><em>x</em> + <em>a</em></span>，语法为<code>$y=bx+a$</code></li>
<li>独立公式，如： <br /><span class="math display"><em>E</em> = <em>m</em><em>c</em><sup>2</sup></span><br /> 语法为<code>$$E=mc^2$$</code></li>
</ol>
</section><section id="如何自动生成-html-文件" class="slide level2">
<h2>如何自动生成 html 文件</h2>
<p>使用 VScode 的 task 功能，可以实现自动执行任务的功能。</p>
<ol type="1">
<li><p>创建如下内容的 task：</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode json"><code class="sourceCode json"><span id="cb4-1"><a href="#cb4-1"></a><span class="fu">{</span></span>
<span id="cb4-2"><a href="#cb4-2"></a>    <span class="dt">&quot;version&quot;</span><span class="fu">:</span> <span class="st">&quot;2.0.0&quot;</span><span class="fu">,</span></span>
<span id="cb4-3"><a href="#cb4-3"></a>    <span class="dt">&quot;tasks&quot;</span><span class="fu">:</span> <span class="ot">[</span><span class="fu">{</span></span>
<span id="cb4-4"><a href="#cb4-4"></a>        <span class="dt">&quot;label&quot;</span><span class="fu">:</span> <span class="st">&quot;生成 html 文档&quot;</span><span class="fu">,</span></span>
<span id="cb4-5"><a href="#cb4-5"></a>        <span class="dt">&quot;type&quot;</span><span class="fu">:</span> <span class="st">&quot;shell&quot;</span><span class="fu">,</span></span>
<span id="cb4-6"><a href="#cb4-6"></a>        <span class="dt">&quot;command&quot;</span><span class="fu">:</span> <span class="st">&quot;pandoc -t revealjs -s demo.md -o demo.html -c yangzh.css&quot;</span><span class="fu">,</span></span>
<span id="cb4-7"><a href="#cb4-7"></a>        <span class="dt">&quot;group&quot;</span><span class="fu">:</span> <span class="fu">{</span></span>
<span id="cb4-8"><a href="#cb4-8"></a>            <span class="dt">&quot;kind&quot;</span><span class="fu">:</span> <span class="st">&quot;build&quot;</span><span class="fu">,</span></span>
<span id="cb4-9"><a href="#cb4-9"></a>            <span class="dt">&quot;isDefault&quot;</span><span class="fu">:</span> <span class="kw">true</span></span>
<span id="cb4-10"><a href="#cb4-10"></a>        <span class="fu">}</span></span>
<span id="cb4-11"><a href="#cb4-11"></a>    <span class="fu">}</span><span class="ot">]</span></span>
<span id="cb4-12"><a href="#cb4-12"></a><span class="fu">}</span></span></code></pre></div></li>
<li><p>执行该 task（快捷键为<code>ctrl+shift+b</code>），即可执行原来需要手工执行的命令，能大大提高预览效率。</p></li>
</ol>
</section><section id="如何分栏显示内容" class="slide level2">
<h2>如何分栏显示内容</h2>
<div class="columns">
<div class="column" style="width:40%;">
<p>左侧栏目</p>
</div><div class="column" style="width:60%;">
<p>右侧栏目内容</p>
<p>右侧栏目内容</p>
<p>右侧栏目内容</p>
</div>
</div>
<p>实现的语法如下：</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode markdown"><code class="sourceCode markdown"><span id="cb5-1"><a href="#cb5-1"></a>:::::::::::::: {.columns}</span>
<span id="cb5-2"><a href="#cb5-2"></a>::: {.column width=&quot;40%&quot;}</span>
<span id="cb5-3"><a href="#cb5-3"></a>左侧栏目</span>
<span id="cb5-4"><a href="#cb5-4"></a>:::</span>
<span id="cb5-5"><a href="#cb5-5"></a>::: {.column width=&quot;60%&quot;}</span>
<span id="cb5-6"><a href="#cb5-6"></a>右侧栏目内容</span>
<span id="cb5-7"><a href="#cb5-7"></a></span>
<span id="cb5-8"><a href="#cb5-8"></a>右侧栏目内容</span>
<span id="cb5-9"><a href="#cb5-9"></a></span>
<span id="cb5-10"><a href="#cb5-10"></a>右侧栏目内容</span>
<span id="cb5-11"><a href="#cb5-11"></a>:::</span>
<span id="cb5-12"><a href="#cb5-12"></a>::::::::::::::</span></code></pre></div>
</section><section id="如何调整演示文档的样式" class="slide level2">
<h2>如何调整演示文档的样式</h2>
<p>通过指定自定义样式表，可以实现演示文档样式的调整。需要创作者熟悉CSS知识。例如：</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode css"><code class="sourceCode css"><span id="cb6-1"><a href="#cb6-1"></a><span class="fu">.reveal</span> h2 {</span>
<span id="cb6-2"><a href="#cb6-2"></a>    <span class="kw">border-left</span>: <span class="dv">0.25</span><span class="dt">em</span> <span class="dv">solid</span> <span class="cn">#6ca0e8</span><span class="op">;</span></span>
<span id="cb6-3"><a href="#cb6-3"></a>}</span></code></pre></div>
<p>上述语法指定了二级标题的左边框宽度、样式及颜色。</p>
</section></section>
<section><section id="参考资料" class="title-slide slide level1"><h1>参考资料</h1></section><section id="在线文档" class="slide level2">
<h2>在线文档</h2>
<ol type="1">
<li><a href="https://pandoc.org/MANUAL.html#producing-slide-shows-with-pandoc" class="uri">https://pandoc.org/MANUAL.html#producing-slide-shows-with-pandoc</a></li>
<li><a href="https://code.visualstudio.com/docs/editor/tasks#vscode" class="uri">https://code.visualstudio.com/docs/editor/tasks#vscode</a></li>
</ol>
</section></section>
    </div>
  </div>

  <script src="reveal.js/js/reveal.js"></script>

  <script>

      // Full list of configuration options available at:
      // https://github.com/hakimel/reveal.js#configuration
      Reveal.initialize({
        // Push each slide change to the browser history
        history: true,

        // Optional reveal.js plugins
        dependencies: [
          { src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
          { src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
          { src: 'reveal.js/plugin/notes/notes.js', async: true }
        ]
      });
    </script>
    </body>
</html>
